package com.als.healthymananger.controller;


import com.als.healthymananger.dto.AppointmentDto;
import com.als.healthymananger.entity.Appointment;
import com.als.healthymananger.utils.RespBean;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


@Tag(name = "预约管理", description = "增删改查")
public interface AppointmentsApi {
    /**
     * 添加预约
     */
    @PostMapping("/")
    @Operation(summary = "添加预约", description = "添加预约", security = @SecurityRequirement(name = "bearer-key"))
    @io.swagger.v3.oas.annotations.parameters.RequestBody(content = @Content(mediaType = "application/json;characterset=UTF-8", schema = @Schema(ref = "appointment")))
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "申请预约成功，等待电话联系"),
            @ApiResponse(responseCode = "400", description = "申请预约失败，等待电话联系")
    })
    public RespBean createAppointmentDto(@RequestBody @Validated AppointmentDto appointment);

    /**
     * 删除预约
     */
    @DeleteMapping("/{appointmentId}")
    @Operation(summary = "删除预约", description = "删除预约", security = @SecurityRequirement(name = "bearer-key"))
    @Parameter(name = "appointmentId", description = "预约序列", in = ParameterIn.PATH, required = true)
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "删除成功"),
            @ApiResponse(responseCode = "400", description = "删除失败")
    })
    public RespBean deleteAppointmentDto(@PathVariable("appointmentId")int appointmentId);

    /**
     * 修改预约
     */
    @PutMapping("/{appointmentId}")
    @Operation(summary = "修改预约", description = "修改预约", security = @SecurityRequirement(name = "bearer-key"))
    @Parameters({
            @Parameter(name = "appointmentId", description = "预约序列", in = ParameterIn.PATH, required = true)
    })
    @io.swagger.v3.oas.annotations.parameters.RequestBody(content = @Content(mediaType = "application/json;characterset=UTF-8", schema = @Schema(ref = "simpleAppointment")), description = "预约信息")
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "修改成功"),
            @ApiResponse(responseCode = "400", description = "修改失败")
    })
    public RespBean updateAppointmentDto(@PathVariable("appointmentId")int appointmentId,
                                 @RequestBody @Validated Appointment appointment);

    /**
     * 获取预约信息
     */
    @GetMapping("/{appointmentId}")
    @Operation(summary = "获取预约信息", description = "获取预约信息", security = @SecurityRequirement(name = "bearer-key"))
    @Parameter(name = "appointmentId", description = "预约序列", in = ParameterIn.PATH, required = true)
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "获取成功"),
            @ApiResponse(responseCode = "400", description = "获取失败")
    })
    public RespBean getAppointmentDto(@PathVariable("appointmentId")int appointmentId);

    /**
     * 获取预约信息
     */
    @GetMapping("/appointments")
    @Operation(summary = "获取预约信息", description = "获取用户自己的预约信息", security = @SecurityRequirement(name = "bearer-key"))
    @Parameter(name = "username", description = "用户名", in = ParameterIn.QUERY, hidden = true, required = true)
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "获取成功"),
            @ApiResponse(responseCode = "400", description = "获取失败")
    })
    public RespBean getAppointmentDtoByUsername(@RequestAttribute("username") String username);

    /**
     * 获取预约信息
     */
    @GetMapping("/appointments/all}")
    @Operation(summary = "获取预约信息", description = "获取预约信息", security = @SecurityRequirement(name = "bearer-key"))
    @Parameter(name = "appointmentId", description = "预约序列", in = ParameterIn.PATH, required = true)
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "获取成功"),
            @ApiResponse(responseCode = "400", description = "获取失败")
    })
    public RespBean getAppointmentDtos();
}
